Hello 4Mosters! Welcome to R Shiny Training with Gissella & Nir!
Before we start training on Friday, please ensure the following libraries, commands and data are loaded, functioning and ready to run! Please ensure you can load all data if you’re unsure about which dataset you would like to use.
Not all these packages/libraries will be used today but having them ready makes life easier. It is quicker to make sure that these are there and working than calling Miles over.
install.packages("shiny")
library(shiny)
install.packages("shinyWidgets") #Upgraded version of widgets
library(shinyWidgets) #To view widget options run the following: shinyWidgetsGallery()
install.packages("DT") #Allows you to view and sort through your data in your app
library(DT)
install.packages("tidyverse")
library(tidyverse)
install.packages("dplyr") #allows for fast data manipulation
library(dplyr)
install.packages("DataExplorer") #Creates an amazing EDA report easily and quickly
library(DataExplorer)
install.packages("ggplot2") #widely used package for plotting
library (ggplot2)
install.packages("plotly") #Will you to wrap ggplots in Plotly
library(plotly)
install.packages("googleVis") #Google's visual package for R - similar to Plotly
library(googleVis)
install.packages("ShinyDashboard") #Allows you to create a dashboard layout easily
library(ShinyDashboard)
install.packages("leaflet") #maps! useful if you would like to viz using a map
library(leaflet)
install.packages("r2d3") #allows you to use d3.js (advanced viz) in R
library(r2d3)
You will be creating a folder structure here, so make sure this is a clean space.
#Find where your current working directory is located
getwd()
#Set path of New working directory -> "C:/MyDocExample/Training"
setwd("<new path>")
You will be working with a partner on one of the following datasets. Please read the dataset descriptions and ensure you have uploaded the datasets beforehand. We will not have enough time for IT issues related to data uploads.
Ensure the following datasets load from your working directory. Code that can be used to upload data:
CRPov = read.csv("Costa_train")
CRPov2 = read.csv("Costa_test") #Optional - test data if you build a model
Click on image to download dataset from T&D dashboard
Ensure the following datasets load from your working directory. Code that can be used to upload Airbnb data:
AirBer = read.csv("listings_summary")
#'listings_summary' - This is the main dataset to use.
#There are optional datasets in the folder which contain additional useful information.
#However, if you don't have much time the dataset above contains most useful info.
Click on image to download dataset from T&D dashboard
To save you some time, check out some useful commands below:
#View first x number of rows of your data
head(mydata, 5)
#View the type and preview of all columns
glimpse(mydata)
#Quick EDA of your data!
summary(mydata)
DataExplorer:::create_report(mydata)
#How to get the unique values of a variable (i.e., like a Proc Freq).
#Useful for knowing what options to input in your widgets!
options = unique(mydata.variable)
Below you can also find usefule R cheatsheets. Click on pictures for downloads R Shiny.
Base R Cheatsheet:
R Shiny Cheatsheet:
ggPlot2 Cheatsheet:
Plotly/R Cheatsheet:
Time-Series Cheatsheet:
Machine Learning in R Cheatsheet: